package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TWithdrawApply;
import com.ruoyi.business.service.ITWithdrawApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现申请Controller
 * 
 * @author laoguo
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/business/withdraw")
public class TWithdrawApplyController extends BaseController
{
    @Autowired
    private ITWithdrawApplyService tWithdrawApplyService;

    /**
     * 查询提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWithdrawApply tWithdrawApply)
    {
        startPage();
        List<TWithdrawApply> list = tWithdrawApplyService.selectTWithdrawApplyList(tWithdrawApply);
        return getDataTable(list);
    }

    /**
     * 导出提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:export')")
    @Log(title = "提现申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWithdrawApply tWithdrawApply)
    {
        List<TWithdrawApply> list = tWithdrawApplyService.selectTWithdrawApplyList(tWithdrawApply);
        ExcelUtil<TWithdrawApply> util = new ExcelUtil<TWithdrawApply>(TWithdrawApply.class);
        util.exportExcel(response, list, "提现申请数据");
    }

    /**
     * 获取提现申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return success(tWithdrawApplyService.selectTWithdrawApplyByApplyId(applyId));
    }

    /**
     * 新增提现申请
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:add')")
    @Log(title = "提现申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWithdrawApply tWithdrawApply)
    {
        return toAjax(tWithdrawApplyService.insertTWithdrawApply(tWithdrawApply));
    }

    /**
     * 修改提现申请
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:edit')")
    @Log(title = "提现申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWithdrawApply tWithdrawApply)
    {
        return toAjax(tWithdrawApplyService.updateTWithdrawApply(tWithdrawApply));
    }

    /**
     * 删除提现申请
     */
    @PreAuthorize("@ss.hasPermi('business:withdraw:remove')")
    @Log(title = "提现申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(tWithdrawApplyService.deleteTWithdrawApplyByApplyIds(applyIds));
    }
}
